function se = SE(data, m, r)
    N = length(data);
    X_m = zeros(N - m + 1, m);
    X_m1 = zeros(N - m, m+1);
    for i = 1:(N - m + 1)
        X_m(i,:) = data(i:i+m-1);
    end
    for i = 1:(N - m)
        X_m1(i,:) = data(i:i+m);
    end

    count_m = 0;
    for i = 1:size(X_m,1)
        for j = i+1:size(X_m,1)
            dist = max(abs(X_m(i,:) - X_m(j,:)));
            if dist <= r
                count_m = count_m + 1;
            end
        end
    end

    count_m1 = 0;
    for i = 1:size(X_m1,1)
        for j = i+1:size(X_m1,1)
            dist = max(abs(X_m1(i,:) - X_m1(j,:)));
            if dist <= r
                count_m1 = count_m1 + 1;
            end
        end
    end

    if count_m == 0 || count_m1 == 0
        se = NaN;
    else
        se = -log(count_m1 / count_m);
    end
end
